home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3523 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.mindlink.net!news
  2. From: genew@mindlink.bc.ca (Gene Wirchenko)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: division problem
  5. Date: Mon, 29 Jan 1996 18:42:26 GMT
  6. Organization: MIND LINK! - British Columbia, Canada
  7. Message-ID: <4ej4ha$66@fountain.mindlink.net>
  8. References: <31097D77.11AA@rain.org> <26JAN199622082450@erich.triumf.ca> <4eh246$u6h@airdmhor.gen.nz>
  9. NNTP-Posting-Host: line038.nwm.mindlink.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. gumboot@airdmhor.gen.nz (Simon Hosie) wrote:
  13.  
  14. >P.Bennett:
  15. >> In order to make it work, you could do:
  16. >>     celsius = (int)((5.0/9.0) * (fahrenheit - 32))
  17. >> The 5.0/9.0 give a meaningful result, and force the multiplication to be done
  18. >> with floats. The (int) will convert the result back to an int.
  19.  
  20. >  That's disgusting!
  21.  
  22. >celcius = (fahrenheit - 32) * 5 / 9;
  23.  
  24.      That's disgusting <g> as it doesn't round.  Try it with 39 deg F:
  25.           (39-32)*5/9 ::= 7*5/9 ::= 35/9 ::= 3
  26. but the actual value is 3.8... i.e. nearly 4.  If you must int, 4
  27. would be a better answer.
  28.  
  29. Sincerely,
  30.  
  31. Gene Wirchenko
  32.  
  33. C Pronunciation Guide:
  34.      y=x++;     "wye equals ex plus plus semicolon"
  35.      x=x++;     "ex equals ex doublecross semicolon"
  36.  
  37.